Coordinated piecewise Bezier vectorization

ABSTRACT

This application is directed to vectoring a raster image in which an electronic device detects a contour of a component in the raster image, builds tangent vectors for each point of the contour and identifies a plurality of segmentation points on the contour. One or more points of sharp angle are identified on the contour in accordance with a determination that each point of sharp angle corresponds to two distinct tangent vectors and that an angle between the two distinct tangent vectors falls below a predefined threshold. A respective one of the segmentation points is positioned at each identified point of shape angle. The electronic device approximates a piecewise smooth fitting curve (e.g., a piecewise Bezier curve) having two or more fitting segments to connect the plurality of segmentation points on the contour. The piecewise smooth fitting curve is thereby provided to vectorize the raster image.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of and claims priority to U.S. patentapplication Ser. No. 15/349,543, filed Nov. 11, 2016, titled“Coordinated Piecewise Bezier Vectorization,” which claims priority toU.S. Provisional Patent Application No. 62/256,332, filed Nov. 17, 2015,and entitled “Coordinated Piecewise Bezier Vectorization,” each of whichis incorporated by reference by its entirety.

TECHNICAL FIELD

This application is directed to the field of image processing, and moreparticularly to the field of approximation of contours in raster imageswith an optimally segmented Bezier curve.

BACKGROUND OF THE INVENTION

Mobile phones with digital cameras are broadly available in nearly everyworldwide market. According to market statistics and forecasts, by 2018,annual smartphone shipments are expected to grow to 1.87 billion units;over 80% of all mobile phones will be arriving to customers withembedded digital cameras. New shipments will expand the already massivecurrent audience of approximately 4.5 billion mobile phone users andseven billion mobile subscribers; new units will also update mobilephones currently used by the subscribers. Annual sales of phone camerasto mobile phone manufacturers for embedding into smartphones and featurephones are projected at 1.5 billion units.

The volume of photographs taken with phone cameras is also growingrapidly. According to recent survey by Pew Research, photographing withphone cameras is the single most popular activity of smartphone ownersutilized by 82% of users. According to recent studies, about 27% of allphotos have been taken with smartphones. Images from smartphone camerasare more and more dominating social photo sharing sites.

Hundreds of millions smartphone users are increasingly incorporatingsmartphone cameras into their information capturing and processinglifestyles at work and at home. Digitizing and capturing paper basedinformation becomes ubiquitous. A recent survey of smartphone usage bymillennials has revealed that 68% of survey respondents have beenintroduced to mobile information capturing via mobile check deposits and83% think that mobile capture will be part of all mobile transactionswithin the next five years. Additionally, business oriented users arecapturing meeting materials and notes from whiteboards, Moleskine andother paper notebooks and other handwritten media. A 2015 study ofcorporate whiteboard users has discovered that 84% of surveyparticipants experienced a need to store whiteboard content;accordingly, 72% had taken a photograph of a whiteboard at least once,while 29% had at least 10 images of whiteboards saved on their cameraenabled smartphones or tablet s. The arrival of unified multi-platformcontent management systems, such as the Evernote service and softwaredeveloped by Evernote Corporation of Redwood City, Calif., aimed atcapturing, storing, displaying and modifying all types and formats ofinformation across all user devices, has facilitated and stimulatedcapturing of typed and handwritten text, documents, forms, checks,charts, drawings and other types and formats of real-life content withsmartphone cameras, as well as other types of cameras and scanners.

Content captured by users using smartphone and other cameras or scannersis initially stored in a content management system as a raster image.Users can view and share such content, but object basedprocessing—selective text modification or copy-pasting, operations withhandwritten doodles or charts, etc.—is not instantly available. Inresponse to this challenge, a variety of content vectorizationmechanisms and systems have been developed, including Roberts, Canny andSobel edge detection methods, Potrace and Vextractor vectorizationsoftware, etc. These mechanisms aim at converting image content intoline art and other traceable object collections.

Notwithstanding a significant progress in vectorization technologies,existing algorithms suffer from significant discrepancies between anoriginal image and a vector representation of the original image. Forexample, Bezier curves that are broadly used in vectorization are oftenapplied inconsistently and distort characteristic features ofhandwritten, typed and hand-drawn shapes, such as sharp angles and highcurvature pieces of a trajectory, which especially affects vectorizationaccuracy and processing capabilities for artistic hand-drawn and printedimages.

Accordingly, it is useful to develop efficient and accurate mechanismsfor vectorization of content captured on raster images.

SUMMARY OF THE INVENTION

According to the system described herein, vectorizing a raster imageincludes identifying a connectivity component in the raster image,detecting a contour of the connectivity component, building tangentvectors for each point of the contour, for each sharp angle of thecontour, positioning a segmentation point of two segments at a pointthereof, for each location of high curvature of the contour, positioningsegments proximal thereto, composing an optimization task to approximatea piecewise Bezier curve, solving the optimization task to provide avectorization of the raster image, and, in response to there not being asufficient number of segments, adding additional segments. Vectorizing araster image may also include applying perspective, color, brightnessand contrast correction to the raster image and building a binaryblack-white representation of the raster image prior to identifying theconnectivity component. The optimization task may minimize a root-meansquare deviation of the piecewise Bezier curve and may providecontinuity and smooth conjugation of adjacent ones of segments of thepiecewise Bezier curve that are not segments corresponding to sharpangles of the contour. There not being a sufficient number of segmentsmay be determined by the deviation of the piecewise Bezier curveexceeding a predefined threshold. The predefined threshold maycorrespond to a root mean square of the deviation being greater than twopixels. The optimization task may be provided using the formula:

${{\sum\limits_{i,j}{{{B\left( t_{j}^{i} \right)} - {C\left( t_{j}^{i} \right)}}}^{2}} + {\sum\limits_{i}^{1}{{\frac{\partial{B\left( t_{n}^{i} \right)}}{\partial t} - \frac{\partial{B\left( t_{1}^{i + 1} \right)}}{\partial t}}}^{2}}}->\min$where ∥⋅∥ is a Euclidean distance, t_(j) ^(i) is a j-th count of an i-thsegment of the contour, t_(n) ^(i) is a symbolic notation for a lastcount of an 1-th segment and t₁ ^(i+1) is a symbolic notation for afirst count of a next i+l-st segment, and B(t_(j) ^(i)), C(t_(j) ^(i)),

$\frac{\partial{B(t)}}{\partial t}$are respectively coordinates on an i-th segment of the Bezier curve, ani-th segment of the contour, and tangent vectors at ends and beginningsof segments of the piecewise Bezier curve that are not segmentscorresponding to sharp angles of the contour. The optimization task maybe solved using a banded matrix corresponding to a system of linearequations. A sharp angle may be determined by the presence of twodistinct left and right tangent vectors where an angle between the twovectors falls below a predefined threshold. The predefined threshold maycorrespond to an angle between the left tangent vector and the righttangent vector being less than ninety degrees. Each location of highcurvature may be determined by a change of direction of the tangentvector within the location exceeding a predefined threshold. Thepredefined threshold may correspond to an angle between two tangentvectors that are twenty pixels apart being greater than 90 degrees. Theraster image may be captured and vectorized using a mobile device.

According further to the system described herein, a non-transitorycomputer-readable medium contains software that vectorizes a rasterimage. The software includes executable code that identifies aconnectivity component in the raster image, executable code that detectsa contour of the connectivity component, executable code that buildtangent vectors for each point of the contour, executable code that, foreach sharp angle of the contour, positions a segmentation point of twosegments at a point thereof, executable code that, for each location ofhigh curvature of the contour, positions segments proximal thereto,executable code that composes an optimization task to approximate apiecewise Bezier curve, executable code that solves the optimizationtask to provide a vectorization of the raster image, and executable codethat, in response to there not being a sufficient number of segments,adds additional segments. The software may also include executable codethat applies perspective, color, brightness and contrast correction tothe raster image and building a binary black-white representation of theraster image prior to identifying the connectivity component. Theoptimization task may minimize a root-mean square deviation of thepiecewise Bezier curve and may provide continuity and smooth conjugationof adjacent ones of segments of the piecewise Bezier curve that are notsegments corresponding to sharp angles of the contour. There not being asufficient number of segments may be determined by the deviation of thepiecewise Bezier curve exceeding a predefined threshold. The predefinedthreshold may correspond to a root mean square of the deviation beinggreater than two pixels. The optimization task may be provided using theformula:

${{\sum\limits_{i,j}{{{B\left( t_{j}^{i} \right)} - {C\left( t_{j}^{i} \right)}}}^{2}} + {\sum\limits_{i}^{1}{{\frac{\partial{B\left( t_{n}^{i} \right)}}{\partial t} - \frac{\partial{B\left( t_{1}^{i + 1} \right)}}{\partial t}}}^{2}}}->\min$where ∥⋅∥ is a Euclidean distance, t_(j) ^(i) is a j-th count of an i-thsegment of the contour, t_(n) ^(i) is a symbolic notation for a lastcount of an i-th segment and t₁ ^(i+1) is a symbolic notation for afirst count of a next i+l-st segment, and B(t_(j) ^(i)), C(t_(j) ^(i)),

$\frac{\partial{B(t)}}{\partial t}$are respectively coordinates on an i-th segment of the Bezier curve, ani-th segment of the contour, and tangent vectors at ends and beginningsof segments of the piecewise Bezier curve that are not segmentscorresponding to sharp angles of the contour. The optimization task maybe solved using a banded matrix corresponding to a system of linearequations. A sharp angle may be determined by the presence of twodistinct left and right tangent vectors where an angle between the twovectors falls below a predefined threshold. The predefined threshold maycorrespond to an angle between the left tangent vector and the righttangent vector being less than ninety degrees. Each location of highcurvature may be determined by a change of direction of the tangentvector within the location exceeding a predefined threshold. Thepredefined threshold may correspond to an angle between two tangentvectors that are twenty pixels apart being greater than 90 degrees. Theraster image may be captured and vectorized using a mobile device.

The proposed system builds a coordinated piecewise Bezier approximationof each contour (boundary) of a connectivity component of a raster imageusing pre-processing of the contour to define segmentation of thecontour taking into account sharp angles and points of high curvatureand using a global optimization function that reflects both thecloseness of each Bezier segment to the original contour and a smoothconjugation of adjacent Bezier segments.

System functioning starts with an initial step of pre-processing araster image where perspective, color, brightness and contrastcorrection are applied to the image and a binary black-whiterepresentation of the image is built. At a next pre-processing step,connectivity components of the binary image are identified andboundaries (contours) of the connectivity components are retrieved usingany of a number of conventional techniques. Each contour is subject tovectorization by the system, which is performed as follows:

-   -   1. Left and right tangent vectors are built for each point of        the contour (with due respect to quantization step of the        curve). For points where the trajectory is smooth, the left and        right vectors coincide. Divergence of the left and right tangent        vectors is an indicator of an angle along the contour.    -   2. All relatively sharp angles on the contour are detected and        serve as initial segmentation points for a piecewise Bezier        approximation. In an embodiment, a sharp angle may be specified        as a point on the trajectory where the left and right tangent        vectors are distinct and form an angle less than 90 degrees.    -   3. Additional points of high curvature of the contour (small        curvature radius but no sharp angle) are identified. For each        identified point, an additional Bezier segment is designated by        placing two extra segmentation points around the identified        point between the identified point and a previously detected        segmentation points from step 2. In an embodiment, curvature of        the contour may be measured in each point of the contour as        follows:        -   a. A 10-pixel interval is taken in each direction from the            point.        -   b. Rotation of the tangent vector between the ends of the            two intervals is measured as a change in direction of the            tangent vector.        -   c. If the change in direction is large enough, for example,            larger than 90 degrees, the point is considered a high            curvature point of the contour.    -   4. If a number of segmentation points on the contour is        insufficient (for example, a long contour has just three        segmentation points defined at steps 2, 3), additional        segmentation points may be designated on the contour, for        example, to split long portions of the contour that lack segment        at ion points from steps 2, 3, into segments of roughly equal        lengths. In an embodiment, addition of new segments may be        driven by an approximation accuracy of the solution of the        global optimization task, as explained below.    -   5. A global optimization task of approximation of the contour by        a piecewise Bezier curve, one Bezier curve per segment, is        formulated and solved. The task is defined by an objective        function that takes into account three factors:        -   a. Minimization of the root-mean-square deviation of the            piecewise Bezier curve from the contour.        -   b. Continuity of piecewise Bezier approximation—the end            point of each segment is the same a starting point of the            next segment.        -   c. Smooth conjugation of adjacent segments at each            segmentation point, except for angles detected at step 2            (minimization of deviation between tangent vectors at an end            of a segment and a start of the next segment).

Based on the above, an objective function may be presented as follows:

${{\sum\limits_{i,j}{{{B\left( t_{j}^{i} \right)} - {C\left( t_{j}^{i} \right)}}}^{2}} + {\sum\limits_{i}^{1}{{\frac{\partial{B\left( t_{n}^{i} \right)}}{\partial t} - \frac{\partial{B\left( t_{1}^{i + 1} \right)}}{\partial t}}}^{2}}}->\min$where ∥⋅∥ is a Euclidean distance; t_(j) ^(i) is a j-th count of an i-thsegment of the contour; in particular, t_(n) ^(i) is a symbolic notationfor a last count of an i-th segment and t₁ ^(i+1) is a symbolic notationfor a first count of a next i+l-st segment; B(t_(j) ^(i)), C(t_(j)^(i)),

$\frac{\partial{B(t)}}{\partial t}$are respectively coordinates on an i-th segment of the Bezier curve, ani-th segment of the contour, and tangent vectors at ends and beginningsof Bezier segments.

It should be noted that because of task segmentation, segment-by-segmenttask composition and adjacency of coordinated segments of the Beziercurve, a matrix of a system of linear equations that solve aminimization task has a banded structure and allows for a quick solutioneven for a high-dimensional task with a large number of segments on theoriginal contour and the corresponding Bezier curve.

After the optimization task is solved, the quality of approximation ofthe contour by Bezier segments and the smoothness of conjugation of thesegments may be additionally evaluated; if any of the quality indicatorsare insufficient, more segmentation points may be added and a newapproximation step with a modified objective function that includes moresegments may be conducted. In an embodiment, new segments may be addedif the root mean square of the deviation is greater than two pixels.

BRIEF DESCRIPTION OF THE DRAWINGS

Embodiments of the system described herein will now be explained in moredetail in accordance with the figures of the drawings, which are brieflydescribed as follows.

FIG. 1 is a schematic illustration of segmentation of a contour on araster image, according to embodiments of the system described herein.

FIG. 2 is a schematic illustration of optimization of a piecewise Bezierapproximation, according to embodiments of the system described herein.

FIG. 3 is a schematic illustration of a banded matrix for a system oflinear equations for the optimization task, according to embodiments ofthe system described herein.

FIG. 4 is a system flow diagram illustrating processing performed inconnection with coordinated piecewise Bezier vectorization, according toembodiments of the system described herein.

DETAILED DESCRIPTION OF VARIOUS EMBODIMENTS

The system described herein provides a mechanism for building highquality vector representations of raster images by using piecewiseBezier approximation of each contour on the original image withcoordinated segment geometry designed to optimize characteristic pointson the contour, such as sharp angles, non-angular points of highcurvature, etc.

FIG. 1 is a schematic illustration 100 of segmentation of a contour on araster image. A contour 110 corresponds to a connectivity component on araster image, as explained elsewhere herein. The contour 110 is suppliedwith tangential vectors built along the contour 110, exemplified by avector 120 a for a point of low curvature and two vectors 120 b, 120 cbuilt for a sharp angle 130 where the continuity of the tangentialvector field may be breaking, so that a particular point on the contourmay have a pair of tangential vectors (for a conventionalcounter-clockwise direction on the contour, the tangential vector 120 bis a left tangential vector, while 120 c is a right tangential vector.

Another type of characteristic points on the contour 110 detected by thesystem corresponds to points of relatively high curvature 140. After allcharacteristic points on the contour 110 have been identified by thesystem, segmentation points are added; as explained elsewhere herein,segmentation points may represent sharp angles on the contour and maysurround points of high curvature. Segmentation points illustrated inFIG. 1 are points 150 a, 150 b, 150 c and includes a point at the sharpangle 130. Subsequently, three sample segments on the contour 110 may bedenoted as a segment 160 a (between the segmentation point 150 a and thepoint at the sharp angle 130), a segment 160 b (between the point at thesharp angle 130 and the segmentation point 150 b) and a segment 160 c(between the segmentation points 150 b, 150 c).

A projection of the segment 160 b is shown separately in FIG. 1, pairedwith a Bezier segment 170 used to build a vector approximation of thecontour 110, as explained elsewhere herein. Additionally, several points180 along the segment 160 b of the contour 110 and corresponding points190 on the Bezier segments 170 are shown.

FIG. 2 is a schematic illustration 200 of optimization of a piecewiseBezier approximation. The contour 110 is approximated by a segmentedBezier curve 210, so that the segments 160 a, 160 b, 160 c areapproximated by corresponding Bezier segments 260 a, 260 b, 260 c.Additional ones of original and approximating segments are depicted inFIG. 2, but aren't enumerated. Accordingly, original segmentationpoints, such as the point at the sharp angle 130 and the point 150 b(i.e. the beginning and the end of the original segment 160 b) obtainanalogs corresponding to segmentation points on the Bezier curve 210,such as points 230, 250 b shown in FIG. 2.

Using notations C(t_(j) ^(i)) for the points 180 of the contour 110 andB(t_(j) ^(i)) for the points 190 on the corresponding Bezier curve 210(a j-th count of an i-th segment), an optimization task 270 may beformulated. A first sum 270 a applies to all points of every segment,while a second sum 270 b (with the superscript 1) applies only to smoothconjugations of adjacent segments, such as at the point 250 b; sharpangles, such as the point 230, are excluded (shown by a black filling ofa corresponding cross mark).

FIG. 3 is a schematic illustration 300 of a banded matrix 310 for asystem of linear equations for an optimization task. The matrix 310 ofthe system of linear equations is symmetric (so that only elements belowa diagonal of the matrix are shown) and is contained within a relativelynarrow band 320 containing triangles 330 and rectangles 340. Each of thetriangles 330 represents an approximation of an original segment by acorresponding Bezier segment, i.e. the segments included in the sum 270a in FIG. 2. Each of the rectangles 330 represents a point of smoothconjugation between two adjacent segments of the Bezier curve, such asthe point 250 b in FIG. 2; the rectangles 340 correspond to the sum 270b in FIG. 2.

Referring to FIG. 4, a flow diagram 400 schematically illustratesprocessing performed in connection with coordinated piecewise Beziervectorization. In an embodiment herein, processing illustrated by theflow diagram 400 may be provided using a mobile device, such as a mobilephone, that may or may not have been used to capturing an image on whichpiecewise Bezier vectorization is performed. Processing starts at a step410 where a raster image is obtained. After the step 410, processingproceeds to a step 415, where the system detects connectivity componentson the image. After the step 415, processing proceeds to a step 420,where the system builds contours for each connectivity component. Afterthe step 420, processing proceeds to a step 425, where a contour isselected. The remainder of the flow diagram 400 describes the processingin connection with the single chosen contour.

After the step 425, processing proceeds to a step 430, where the systemlocates sharp angles on the contour (see, for example, FIG. 1 and theaccompanying text related to the point at the sharp angle 130). Afterthe step 430, processing proceeds to a test step 435, where it isdetermined whether any sharp angles are present. If so, processingproceeds to a step 440 where segmentation points of the original contourare positioned at points of the sharp angles. After the step 440,processing proceeds to a step 445, where the system locates points ofhigh curvature on the original contour, as explained elsewhere herein.Note that the step 445 may be independently reached from the test step435 in the event when there are no sharp angles on the contour.

After the step 445, processing proceeds to a test step 450, where it isdetermined whether any high curvature points are present. If so,processing proceeds to a step 455 where segmentation points of thecontour are augmented with additional points positioned around highcurvature point s, as explained elsewhere herein. After the step 455,processing proceeds to a test step 460, where it is determined whetherthere are enough segmentation points on the contour. Note that the teststep 460 may be independently reached from the test step 450 if no highcurvature points were present on the con tour. If there are not enoughsegmentation point s on the contour, processing proceeds to a step 465where uniform segmentation point s are added along the contour. Afterthe step 465, processing proceeds to a step 470 where an optimizationtask for identifying a segmented Bezier curve is composed, as explainedelsewhere herein (see, in particular, FIG. 2 and the accompanying text).

After the step 470, processing proceeds to a step 475 where a bandedmatrix for the system of linear equations representing the optimizationtask is built (depicted in FIG. 3 and explained in the accompanyingtext). After the step 475, processing proceeds to a step 480 where theoptimization task is solved and coordinated Bezier segments areidentified. After the step 480, processing proceeds to a test step 485,where it is determined whether the approximation of the original contouris sufficient. If so, processing is complete; otherwise, processingproceeds back to the step 465 to add more segmentation points.

Various embodiments discussed herein may be combined with each other inappropriate combinations in connection with the system described herein.Additionally, in some instances, the order of steps in the flowcharts,flow diagrams and/or described flow processing may be modified, whereappropriate. Subsequently, elements and areas of screen described inscreen layouts may vary from the illustrations presented herein.Further, various aspects of the system described herein may beimplemented using soft war e, hardware, a combination of software andhardware and/or other computer-implemented modules or devices having thedescribed features and performing the described functions. Capturing ofraster images may be done using smartphones, tablets and other mobiledevices with embedded cameras, as well as conventional cameras, scannersand other hardware.

Software implementations of the system described herein may includeexecutable code that is stored in a computer readable medium andexecuted by one or more processors, including one or more processors ofa desktop computer. The desktop computer may receive input from acapturing device that may be connected to, part of, or otherwise incommunication with the desktop computer. The desktop computer mayinclude software that is pre-loaded with the device, installed from anapp store, installed from media such as a CD, DVD, etc., and/ordownloaded from a Web site. The computer readable medium may benon-transitory and include a computer hard drive, ROM, RAM, flashmemory, portable computer storage media such as a CD-ROM, a DVD-ROM, aflash drive, an SD card and/or other drive with, for example, auniversal serial bus (USB) interface, and/or any other appropriatetangible or non-transitory computer readable medium or computer memoryon which executable code may be stored and executed by a processor. Thesystem described herein may be used in connection with any appropriateoperating system.

Other embodiments of the invention will be apparent to those skilled inthe art from a consideration of the specification or practice of theinvention disclosed herein. It is intended that the specification andexamples be considered as exemplary only, with the true scope and spiritof the invention being indicated by the following claims.

What is claimed is:
 1. A method of vectorizing a raster image,comprising: at an electronic device including one or more processors andmemory: detecting a contour of a component in the raster image; buildingtangent vectors for each point of the contour; identifying a pluralityof segmentation points on the contour, the plurality of segmentationpoints including one or more first segmentation points, including:identifying one or more points of sharp angle on the contour inaccordance with a determination that each of the one or more points ofsharp angle has two distinct left and right tangent vectors originatingfrom the respective point of sharp angle and that an angle between thetwo distinct left and right tangent vectors of each of the one or morepoints of sharp angle falls below a first predefined threshold; andpositioning a respective one of the one or more first segmentationpoints at each identified point of sharp angle, each point of sharpangle connecting two first segments on the contour; approximating apiecewise smooth fitting curve to connect the plurality of segmentationpoints on the contour, the piecewise smooth fitting curve including twoor more fitting segments each of which is configured to connect twoneighboring points of the plurality of segmentation points; and inaccordance with the piecewise smooth fitting curve, providing avectorization of the raster image.
 2. The method of claim 1, wherein theplurality of segmentation points including one or more secondsegmentation points, and identifying the plurality of segmentationpoints on the contour further includes: identifying one or morelocations of high curvature in accordance with a determination that achange of direction of the tangent vectors at each location of highcurvature exceeds a second predefined threshold; for each of the one ormore locations of high curvature, positioning two second segmentsproximal to each location of high curvature to connect the respectivelocation of high curvature to second segmentation points on the contour.3. The method of claim 2, wherein the second predefined thresholdcorresponds to an angle between two tangent vectors of points on eachlocation of high curvature that are twenty pixels apart, the angle beinggreater than 90 degrees.
 4. The method of claim 1, further comprising:in accordance with a determination that the piecewise smooth fittingcurve does not match the contour, adding one or more segmentation pointsto create additional segments.
 5. The method of claim 4, furthercomprising: determining that the piecewise smooth fitting curve does notmatch the contour in accordance with a determination determining adeviation of the piecewise smooth fitting curve from the contour exceedsa predefined deviation threshold.
 6. The method of claim 5, wherein thepredefined deviation threshold corresponds to a root mean square of thedeviation of the piecewise smooth fitting curve being greater than twopixels.
 7. The method of claim 1, further comprising: minimizing aroot-mean square deviation of the piecewise smooth fitting curve fromthe contour; and providing continuity and smooth conjugation of adjacentones of the fitting segments, of the piecewise smooth fitting curve,that are not connected to any of the one or more points of sharp angleon the contour.
 8. The method of claim 1, further comprising: providinga root-mean square deviation of the piecewise smooth fitting curve fromthe contour, wherein the root-mean square deviation is minimized using aformula of:${{\sum\limits_{i,j}{{{B\left( t_{j}^{i} \right)} - {C\left( t_{j}^{i} \right)}}}^{2}} + {\sum\limits_{i}^{1}{{\frac{\partial{B\left( t_{n}^{i} \right)}}{\partial t} - \frac{\partial{B\left( t_{1}^{i + 1} \right)}}{\partial t}}}^{2}}}->\min$where ⋅ ^(•) ⋅ is a Euclidean distance, t is a pixel count on a segmentof the contour, t_(j) ^(i) is a j-th count of an i-th segment of thecontour, t_(n) ^(i) is a symbolic notation for a last count of an i-thsegment and t₁ ^(i)+1 is a symbolic notation for a first count of a nexti+1-st segment, and B(t_(j) ^(i)), C(t_(j) ^(i)),$\frac{\partial{B(t)}}{\partial t}$ are respectively coordinates on ani-th segment of the smooth fitting curve, an i-th segment of thecontour, and tangent vectors at ends and beginnings of segments of thepiecewise smooth fitting curve that are not the first segmentscorresponding to sharp angles of the contour.
 9. The method of claim 8,wherein the root-mean square deviation is minimized using a bandedmatrix corresponding to a system of linear equations.
 10. The method ofclaim 1, further comprising: applying perspective, color, brightness andcontrast correction to the raster image; and building a binaryblack-white representation of the raster image prior to detecting thecontour of the component.
 11. An electronic device, comprising: one ormore processors; and memory having instructions stored thereon, whichwhen executed by the one or more processors cause the electronic deviceto perform: detecting a contour of a component in a raster image;building tangent vectors for each point of the contour; identifying aplurality of segmentation points on the contour, the plurality ofsegmentation points including one or more first segmentation points,including: identifying one or more points of sharp angle on the contourin accordance with a determination that each of the one or more pointsof sharp angle has two distinct left and right tangent vectorsoriginating from the respective point of sharp angle and that an anglebetween the two distinct left and right tangent vectors of each of theone or more points of sharp angle falls below a first predefinedthreshold; and positioning a respective one of the one or more firstsegmentation points at each identified point of sharp angle, each pointof sharp angle connecting two first segments on the contour;approximating a piecewise smooth fitting curve to connect the pluralityof segmentation points on the contour, the piecewise smooth fittingcurve including two or more fitting segments each of which is configuredto connect two neighboring points of the plurality of segmentationpoints; and in accordance with the piecewise smooth fitting curve,providing a vectorization of the raster image.
 12. The electronic deviceof claim 11, wherein the first predefined threshold corresponds to anangle between a left tangent vector and a right tangent vector beingless than ninety degrees.
 13. The electronic device of claim 11, whereinthe electronic device is a mobile device, and the raster image iscaptured and vectorized using the mobile device.
 14. The electronicdevice of claim 11, wherein the plurality of segmentation pointsincluding one or more second segmentation points, and identifying theplurality of segmentation points on the contour further includes:identifying one or more locations of high curvature in accordance with adetermination that a change of direction of the tangent vectors at eachlocation of high curvature exceed a second predefined threshold; foreach of the one or more locations of high curvature, positioning twosecond segments proximal to each location of high curvature to connectthe respective location of high curvature to second segmentation pointson the contour.
 15. The electronic device of claim 14, wherein thesecond predefined threshold corresponds to an angle between two tangentvectors of points on each location of high curvature that are twentypixels apart, the angle being greater than 90 degrees.
 16. Anon-transitory computer-readable medium, having one or more programsstored thereon, which when executed by one or more processors of anelectronic device, cause the electronic device to perform operations forvectorizing a raster image, the one or more programs further comprisinginstructions for: detecting a contour of a component in the rasterimage; building tangent vectors for each point of the contour;identifying a plurality of segmentation points on the contour, theplurality of segmentation points including one or more firstsegmentation points, including: identifying one or more points of sharpangle on the contour in accordance with a determination that each of theone or more points of sharp angle has two distinct left and righttangent vectors originating from the respective point of sharp angle andthat an angle between the two distinct left and right tangent vectors ofeach of the one or more points of sharp angle falls below a firstpredefined threshold; and positioning a respective one of the one ormore first segmentation points at each identified point of sharp angle,each point of sharp angle connecting two first segments on the contour;approximating a piecewise smooth fitting curve to connect the pluralityof segmentation points on the contour, the piecewise smooth fittingcurve including two or more fitting segments each of which is configuredto connect two neighboring points of the plurality of segmentationpoints; and in accordance with the piecewise smooth fitting curve,providing a vectorization of the raster image.
 17. The non-transitorycomputer-readable medium of claim 16, wherein continuity of the tangentvectors for the contour is broken at each of the one or more points ofsharp angle.
 18. The non-transitory computer-readable medium of claim16, further comprising: in accordance with a determination that thepiecewise smooth fitting curve does not match the contour, adding one ormore segmentation points to create additional segments.
 19. Thenon-transitory computer-readable medium of claim 18, further comprising:determining that the piecewise smooth fitting curve does not match thecontour in accordance with a determination that a deviation of thepiecewise smooth fitting curve from the contour exceeds a predefineddeviation threshold.
 20. The non-transitory computer-readable medium ofclaim 19, wherein each of two or more fitting segments of the piecewisesmooth fitting curve is generated based on a respective Bezier curveconfigured to connect the respective two neighboring points of theplurality of segmentations points on the contour.